<template>
	<view>
		<image src="/static/icon_3bj.png" class="w100 absolute" mode="widthFix"></image>
    <uni-nav-bar backgroundColor="rgba(0,0,0,0)" class="mb-56" :border="false">
      <!-- <view class="" slot="right">
        <image src="/static/icon_3sys.png" class="w-44 h-44" mode=""></image>
      </view> -->
    </uni-nav-bar>
    
    <view class="w100 rowsc rowsm fs-36 fw-b col000 relative mb-86">劳动教育-教师端</view>
    
    <view class="w100 pl-24 pr-24 relative">
      <view class="w100 h-100 br-20 bgff pl-28 pr-28 rows rowsm mb-24" @click="$tools.goNext('/pages/msg/notice')">
        <image src="/static/notice.png" class="w-65 h-26 mr-20" mode=""></image>
        <view class="w-16 h-16 br-8 mr-20" style="background: linear-gradient(to bottom,#4897FF,#4878FF);"></view>
         <view class="w100">
          <uni-notice-bar single scrollable backgroundColor="rgba(0,0,0,0)" style="margin: 0;padding: 0;" :text="info" color="#888"></uni-notice-bar>
        </view>
      </view>
      
      <view class="w100 rowsb rowsm mb-32">
        <image src="/static/icon_3sp.png" class="w-344 h-240" mode="" @click="$tools.goNext('/pagesCopy/index/check')"></image>
        <image src="/static/icon_-1.png" class="w-344 h-240" mode="" @click="$tools.goNext('/pagesCopy/index/classList2')"></image>
      </view>
      <view class="w100 rowsb rowsm mb-20">
        <view class="fs-30 col333 fw-b">政策资讯</view>
        <view class="fs-24" style="color: #707070;" @click="$tools.goNext('/pages/index/newsList')">更多>></view>
      </view>
      
      <view class="w100 p-all-24 bgff br-20 rowscl mb-20" v-for="(item,index) in list" :key="index" @click="$tools.goNext('/pages/index/newsDetail?id=' + item.id)">
        <view class="rows rowsm fs-28 col666 mb-30">{{item.title}}</view>
        <view class="rows rowsm fs-24 col888" style="flex-direction: row-reverse;">{{item.createTime}}</view>
      </view>
    </view>
	</view>
</template>

<script>
	export default {
			data() {
				return {
					list:[],
          info:'',
          total:0,
        limit: {
          pageNum: 1,
          pageSize: 10
        },
				}
			},
			onLoad() {
				this.getList()
				// this.getList1()
			},
    // 下拉到底部后加载新数据
    onReachBottom() {
      if (this.list.length < this.total) {
        this.limit.pageNum++;
        this.getList()
      }
    },
    onPullDownRefresh() {
      this.limit.pageNum = 1
      this.getList()
    },
			methods: {
				getList(){
          this.$tools.axiosFromToken('POST',`prozczx/listRed?pageNum=${this.limit.pageNum}&pageSize=${this.limit.pageSize}`,{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            // let {rows} = res
            // this.list = rows
            //  取前4条数据
            if( res.rows.length>4){
              this.list = res.rows.slice(0,4)
            }else{
              this.list = res.rows
            }
            
            
          })
          
          this.$tools.axiosFromToken('POST','pronotice/list',{},'加载中').then(res => {
            if(res.code != 200) return this.$tools.showtt(res.msg)
            let {rows} = res
            this.info = rows[0].name
          })
        },
        getList1() {
          const requests = [
            'pronotice/list',
            'prold/terListMsg',
            'proldzj/terListMsg',
            'proldcg/terListMsg',
            'proldgy/terListMsg',
            'prouserdc/listTer'
          ].map(url =>
            this.$tools.axiosFromToken('POST', `${url}?pageNum=1&pageSize=10`, {}, '加载中')
          );
          Promise.all(requests).then(responses => {
            let noticeTotal = 0;
            responses.forEach(res => {
              if (res.code != 200) {
                throw new Error(res.msg);
              }
              noticeTotal += res.total;
            });
            uni.setTabBarBadge({
              index: 1,
              text: String(noticeTotal),
            });
          }).catch(error => {
            this.$tools.showtt(error.message);
          });
        }
			},
		}
</script>

<style lang="scss">
	page {
		background: #f7f6fa;
	}
</style>
